const path = require('path');
import { configure, getLogger, Logger } from "log4js";

configure({
  appenders: {
    access: {
      type: process.env.NODE_ENV==="production"? 'dateFile':'console',
      pattern: '-yyyy-MM-dd.log', //生成文件的规则
      filename: path.join('logs/', 'access.log') //生成文件名
    },
    application: {
      type: 'dateFile',
      pattern: '-yyyy-MM-dd.log',
      filename: path.join('logs/', 'application.log')
    },
    out: {
      type: 'console'
    }
  },
  categories: {
    default: { appenders: [ 'out' ], level: 'debug' },
    access: { appenders: [ 'access' ], level: 'debug' },
    application: { appenders: [ 'application' ], level: 'WARN'}
  }
});
export  function getLog (mode?:string):Logger{
    return getLogger(mode)
}

